package com.woniuxy.juc.reentrant;

import com.woniuxy.untis.Sleep;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.ReentrantLock;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO:
 * <P> Date: 2022/4/11:12:56
 * <P> Description:
 */
@Slf4j(topic = "c.c")
@SuppressWarnings("all")
public class SourceTest {
    public static void main(String[] args) {
        ReentrantLock lock = new ReentrantLock();
        lock.newCondition().signal();
        new Thread(()->{
            lock.lock();
//            log.debug("locking...");

            try {
                log.debug("locking...");
                Sleep.sleep(5L);
            }finally {
                log.debug("unlocking...");
                lock.unlock();
            }
        },"t1").start();

        new Thread(()->{
            lock.lock();

            try {
                log.debug("locking...");
            }finally {
                log.debug("unlocking...");
                lock.unlock();
            }
        },"t2").start();
    }
}
